package main

import (
	"fmt"
	"net/http"
	"net/http/cookiejar"
	"io/ioutil"
	"net/url"
)

func main() {

	cJar, err := cookiejar.New(nil)
	if err != nil {
		fmt.Println(err)
		return
	}
	client := &http.Client{
		Jar: cJar,
	}

    loginUrl1 := "https://www.mint.com/"

    respLogin, err := client.Get(loginUrl1)
    defer respLogin.Body.Close()

    loginUrl2 := "https://wwws.mint.com/loginJumper.event"

    respLogin2, err := client.PostForm(loginUrl2,
    	url.Values{
			"username": {"" },
			"password": {""},
			"task": {"L"},
    	})

    fmt.Println(respLogin2.Status)
    defer respLogin2.Body.Close()
    //https://wwws.mint.com/transactionDownload.event

    respLogin3, err := client.PostForm("https://wwws.mint.com/loginUserSubmit.xevent",
    	url.Values{
			"username": {"" },
			"password": {""},
			"task": {"L"},
    	});
	fmt.Println(respLogin3.Status)
    defer respLogin3.Body.Close()

    resp, err := client.Get("https://wwws.mint.com/transactionDownload.event")
    //resp, err := client.Get("https://wwws.mint.com/transaction.event")
    defer resp.Body.Close()

    csv, err := ioutil.ReadAll(resp.Body)

    fmt.Println(string(csv))
}